<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
    <title>
        MIS管理系统
    </title>
    <link href="${pageContext.request.contextPath}/easyui/themes/default/easyui.css" rel="stylesheet" type="text/css"/>
    <link href="${pageContext.request.contextPath}/css/wu.css" rel="stylesheet" type="text/css"/>
    <link href="${pageContext.request.contextPath}/css/icon.css" rel="stylesheet" type="text/css"/>
    <link href="${pageContext.request.contextPath}/Uploadify/uploadify.css" rel="stylesheet"/>
    <script src="${pageContext.request.contextPath}/js/jquery-1.8.0.min.js"></script>
    <script src="${pageContext.request.contextPath}/Uploadify/jquery.uploadify.min.js"></script>
    <script src="${pageContext.request.contextPath}/easyui/jquery.easyui.min.js"></script>
    <script src="${pageContext.request.contextPath}/easyui/jquery.easyui.extends.min.js"></script>
    <script src="${pageContext.request.contextPath}/easyui/locale/easyui-lang-zh_CN.js" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/js/jquery.form.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/jquery.seat-charts.min.js"></script>
    <script>
    	
    	<!--
        var PUBLIC = '__PUBLIC__';
        var Url = '{:U("Communal/uploadFace","","")}';
        var sid = '{:session_id()}';
        var ROOT = '__ROOT__';
        var nationUrl = PUBLIC + "/xml/Nation.xml";
        var departmentUrl = "{:U('Home/Communal/getDepartment','','')}";
        var majorUrl = "{:U('Home/Communal/getMajorData','','')}";
        var dormUrl = "{:U('Home/Communal/getDormData','','')}";
        var getCurrentDormTotalUrl = "{:U('Home/Communal/getCurrentDormTotal','','')}";
        var registrationUrl = "{:U('Home/Registration/doRegistration','','')}";
        var totalNumberReportUrl = "{:U('Home/Registration/totalNumberReport','','')}";
        var studentListUrl = "{:U('Home/Registration/getStudentListByPage','','')}";
        var doImportUrl = "{:U('Home/SystemSetting/doImport','','')}";
        var doExportUrl = "{:U('Home/SystemSetting/doExport','','')}";
        var queryStudentUrl = "{:U('Home/Registration/getStudentByNoticeNumber','','')}";
        var getCurrentDormInfoUrl = "{:U('Home/Registration/getCurrentDormInfo','','')}";
        var doDisDormUrl = "{:U('Home/Registration/doDisDorm','','')}";
        var getUserMenuUrl = "{:U('Home/Communal/getUserMenu','','')}";
        
        var getRoleListUrl = "{:U('Home/User/getRoleList','','')}";
        var getUserListByPageUrl = "{:U('Home/User/getUserListByPage','','')}";
        var resetPwdUrl = "{:U('Home/User/resetPwd','','')}";
        var editUserStatusUrl = "{:U('Home/User/editUserStatus','','')}";
        var checkUserUrl = "{:U('Home/Communal/checkUser','','')}";
        var SaveUserUrl = "{:U('Home/User/SaveUser','','')}";
        var getRoleListByPageUrl = "{:U('Home/User/getRoleListByPage','','')}";
        var checkRoleNameUrl = "{:U('Home/Communal/checkRoleName','','')}";
        var doSaveUserRoleUrl = "{:U('Home/User/doSaveUserRole','','')}";
        var getUserRoleUrl = "{:U('Home/User/getUserRole','','')}";
        var getMenuListByPageUrl = "{:U('Home/SystemSetting/getMenuListByPage','','')}";
        var doEditMenuUrl = "{:U('Home/SystemSetting/doEditMenu','','')}";
        var checkMenuNameUrl = "{:U('Home/Communal/checkMenuName','','')}";
        var doSaveDormUrl = "{:U('Home/BaseData/doSaveDorm','','')}";
        var doSaveDepartmentUrl = "{:U('Home/BaseData/doSaveDepartment','','')}";
        var doSaveMajorUrl = "{:U('Home/BaseData/doSaveMajor','','')}";
        var getDepartmentByPageUrl = "{:U('Home/BaseData/getDepartmentByPage','','')}";
        var getMajorByPageUrl = "{:U('Home/BaseData/getMajorByPage','','')}";
        var getDormByPageUrl = "{:U('Home/BaseData/getDormByPage','','')}";
        -->
        var getUserMenuUrl = "${pageContext.request.contextPath}/system/user/userMenuList.do";
        var getRoleListByPageUrl = "${pageContext.request.contextPath}/system/role/roleListByPage.do";
        var getMenuListByPageUrl = "${pageContext.request.contextPath}/system/menu/menuListByPage.do";
        var getUserListByPageUrl = "${pageContext.request.contextPath}/system/user/userListByPage.do";
        var getAllMenuUrl = "${pageContext.request.contextPath}/system/menu/sysMenuList.do";
        var doDisAuthUrl = "${pageContext.request.contextPath}/system/role/doDisAuth.do";
        var treeData;
        $(function () {
            $.ajax({
                url: getUserMenuUrl,
                type: 'post',
                datatype: 'json',
                async: false,
                success: function (result) {
                    treeData = InitTreeData(result);
                }
            });
            //初始化树形菜单
            $("#tree").tree({
                data: treeData,
                lines: false,
                onClick: function (node) {
                    if (node.attributes.url != null && node.attributes.url != '') {
                        addTab(node.text, node.attributes.url, node.iconCls, parseInt(node.iframe));
                    }
                },onLoadSuccess: function (node, data) {
                    if(data){
                        $(this).tree('expand',$(this).tree('getRoot').target);
                    }
                }
            });
        });
        function InitTreeData(data) {
            if (!data)
                return [];
            var treeData = []; //最终返回结果
            var treeArray = {}; //记录一级节点
            var root = 0; //最顶层节点的父id
            var idKey = "id"; //主键的键名
            var pidKey = "pid"; //父ID的键名
            getChildren(root);
            function getChildren($root) {
                var $children = [];
                for (var i in data) {
                    if ($root == data[i][pidKey]) {
                        data[i]["children"] = getChildren(data[i][idKey]);
                        $children.push(data[i]);
                    }
                    if (root == data[i][pidKey] && !treeArray[data[i][idKey]]) {
                        treeArray[data[i][idKey]] = data[i];
                        treeData.push(data[i]);
                    }
                }
                return $children;
            }
            return treeData;
        }
        function editpassword(){
            addTab('修改密码','/StudentRegistration/Home/Communal/editPwd','icon-cog',0);
        }
        function addTab(title, href, iconCls, iframe) {
            var tabPanel = $('#wu-tabs');
            if (!tabPanel.tabs('exists', title)) {
                var content = '<iframe scrolling="auto" frameborder="0"  src="${pageContext.request.contextPath}' + href + '" style="width:100%;height:100%;"></iframe>';
                if (iframe) {
                    tabPanel.tabs('add', {
                        title: title,
                        content: content,
                        iconCls: iconCls,
                        fit: true,
                        cls: 'pd3',
                        closable: true
                    });
                } else {
                    tabPanel.tabs('add', {
                        title: title,
                        href: "${pageContext.request.contextPath}" + href,
                        iconCls: iconCls,
                        fit: true,
                        cls: 'pd3',
                        closable: true
                    });
                }
            } else {
                tabPanel.tabs('select', title);
            }
        }

        /**
         * Name 移除菜单选项
         */
        function removeTab() {
            var tabPanel = $('#wu-tabs');
            var tab = tabPanel.tabs('getSelected');
            if (tab) {
                var index = tabPanel.tabs('getTabIndex', tab);
                tabPanel.tabs('close', index);
            }
        }

        /**
         *移除所有菜单项
         */
        function closeAll() {
            $.messager.confirm('清除缓存', '确认是否关闭所有选项卡清除缓存?', function (r) {
                if (r) {
                    $("#wu-tabs li").each(function (index, obj) {
                        //获取所有可关闭的选项卡
                        var tab = $(".tabs-closable", this).text();
                        $(".easyui-tabs").tabs('close', tab);
                    });
                    $("#close").remove(); //同时把此按钮关闭
                }
            });
        }

        //将时间戳转换成日期
        function toDateString(d, format) {
            var date = new Date(d || new Date()),
                ymd = [
                    this.digit(date.getFullYear(), 4), this.digit(date.getMonth() + 1), this.digit(date.getDate())
                ];
            format = format || 'yyyy年MM月dd日';
            return format.replace(/yyyy/g, ymd[0]).replace(/MM/g, ymd[1]).replace(/dd/g, ymd[2]);
        };

        //数字前置加零
        function digit(num, length, end) {
            var str = '';
            num = String(num);
            length = length || 2;
            for (var i = num.length; i < length; i++) {
                str += '0';
            }
            return num < Math.pow(10, length) ? str + (num | 0) : num;
        }


        //弹出加载层
        function load(msgtext) {
            $("<div class=\"datagrid-mask\" id='bodymask' style='z-index:100001'></div>").css({
                display: "block",
                width: "100%",
                height: $("body").height()
            }).appendTo("body");
            $("<div class=\"datagrid-mask-msg\" id='bodymask-msg'  style='z-index:100001' ></div>").html(msgtext).appendTo("body").css({
                display: "block",
                position: "fixed",
                left: ($(document.body).outerWidth(true) - 190) / 2,
                top: ($(window).height() - 45) / 2
            });
            // $.messager.progress({
            //     title: '系统提示',
            //     msg: msgtext,
            //     text: ''
            // });
        }

        //取消加载层
        function disLoad() {
            $(".datagrid-mask").remove();
            $(".datagrid-mask-msg").remove();
            // $.messager.progress('close');
        }

        function showTime() {
            dt = new Date();
            var show_day = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
            year = dt.getFullYear();
            month = dt.getMonth() + 1;
            date = dt.getDate();
            day = dt.getDay();
            hours = dt.getHours();
            hours = hours < 10 ? "0" + hours : hours;
            minutes = dt.getMinutes();
            minutes = minutes < 10 ? "0" + minutes : minutes;
            seconds = dt.getSeconds();
            seconds = seconds < 10 ? "0" + seconds : seconds;
            dtime = year + "-" + month + "-" + date + "  " + show_day[day] + "  " + hours + ":" + minutes + ":" + seconds;
            $("#nowTime").html(dtime);
            setTimeout("showTime()", 1000);
        }
    </script>
</head>
<body class="easyui-layout" onload="showTime()">
<!-- begin of header -->
<div class="wu-header" data-options="region:'north',border:false,split:true">
    <div class="wu-header-left">
        <h1>
            MIS管理系统
        </h1>
    </div>
    <div class="wu-header-right">
        <p>
            欢迎 ${system_admin_login_info.username}
            <a href="javascript:void(0)" onclick="editpassword();">修改密码</a>
            |
            <a href="#" onclick="closeAll()">
                清除缓存
            </a>
            |
            <a href="${pageContext.request.contextPath}/login_out.do">
                安全退出
            </a>
        </p>
        <p>
            <a id="nowTime">
            </a>
        </p>
    </div>
</div>
<!-- end of header -->
<!-- begin of sidebar -->
<div class="wu-sidebar" data-options="region:'west',split:true,border:true,title:'导航菜单'">
    <div class="easyui-accordion" data-options="border:false,fit:true">
        <ul id="tree">
        </ul>
    </div>
</div>
<!-- end of sidebar -->
<!-- begin of main -->
<div class="wu-main" data-options="region:'center'">
    <div class="easyui-tabs" data-options="border:false,fit:true" id="wu-tabs">
        <div data-options="href:'info.jsp',closable:false,iconCls:'icon-tip',cls:'pd3'"
             title="欢迎使用">
        </div>
    </div>
</div>
<!-- end of main -->
<!-- begin of footer -->
<div class="wu-footer" data-options="region:'south',border:true,split:true">
    © 2018 Copy Rights Reserved
</div>
<!-- end of footer -->
</body>
</html>